package composant;

import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class btnPicture extends JButton implements MouseListener{

	/**
	 * test
	 */
	private static final long serialVersionUID = 1L;

	public btnPicture(String chemin) {
		this.addMouseListener(this);
		this.setBorderPainted(false);
		this.setContentAreaFilled(false);
		this.setFocusPainted(false);
		this.setIcon(new ImageIcon(this.getClass().getResource("/img/" + chemin + ".png")));
	}

	private void drawBorder(boolean value){
		this.setFocusPainted(value);
	}
	@Override
	public void mouseClicked(MouseEvent arg0) {
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		setCursor(Cursor.getDefaultCursor());
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		drawBorder(true);
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {	
		drawBorder(false);
	}
}
